package com.example.test.springMVC.config;

import com.example.test.util.StringToBaseEnumConverterFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    /**
     * String -> BaseEnum子类
     **/
    @Override
    public void addFormatters(FormatterRegistry registry) {
        registry.addConverterFactory(new StringToBaseEnumConverterFactory());
    }

    /**
     * 跨域访问
     **/
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/biz/**");
        registry.addMapping("/sys/**");
    }
}
